namespace gen {

	template <class LimitT, class OperatorT, class CondT>
	template <typename ContextT>
	domain<typename ContextT::iterator_t>
	number<LimitT,OperatorT,CondT>::evaluate(ContextT const& c) const
    {
		typedef typename LimitT::iterator_t		iterator_t;
		typedef typename LimitT::context_t		context_t;
		typedef typename ContextT::iterator_t	domain_iterator_t;
		
		int nb_value = m_value;
		// construct temporary context
		iterator_t first = m_limit_start.get_limit(c);
		iterator_t last = m_limit_end.get_limit(c);
		context_t tmp(first, last, c);
		// evaluate expression
		domain<iterator_t> result = m_expr.evaluate(tmp);
		// nb positives mandatory
		if (m_value==ALL_ITEMS) nb_value = last - first;
		// compare nb positives
		if (m_op(result.nbPositives(), nb_value)) {
			return c.domain();
		}
		return domain<domain_iterator_t>(c.domain().first(), c.domain().last(), false_initializator());
    }

    template <class LimitT, class OperatorT, class CondT>
    inline number<LimitT, OperatorT, CondT>
    nbOfValid_g(int value, LimitT const& start, LimitT const& end, OperatorT const& op, CondT const& c)
	{
		return number<LimitT, OperatorT, CondT>(value, start, end, op, c); 
	}

    template <class LimitT, class OperatorT>
    inline number<LimitT, OperatorT>
    nbOfValid_g(int value, LimitT const& start, LimitT const& end, OperatorT const& op)
	{
		return number<LimitT, OperatorT>(value, start, end, op); 
	}

    template <class LimitT>
    inline number<LimitT>
    nbOfValid_g(int value, LimitT const& start, LimitT const& end)
    { 
        return number<LimitT>(value, start, end); 
    }

    template <class LimitT>
    inline number<LimitT>
    nbOfValid_g(int value, LimitT const& start)
    { 
        return number<LimitT>(value, start); 
    }
}
